using System;
using System.Collections.Generic;
using System.Text;
using CodePlex.Resourceful.Amazon.SimpleDB;

namespace CodePlex.Resourceful.Examples
{
    public static class SimpleDBExample
    {

        public static void Run()
        {
            string aws = Environment.GetEnvironmentVariable("AWS");

            string accessKeyID = aws.Split(':')[0];
            string secretAccessKey = aws.Split(':')[1];


            SimpleDBClient client = new SimpleDBClient(accessKeyID, secretAccessKey,false);
            client.Tracer.AddListener(Console.Out);


            
            ClientResponse r;
            NameValuePairs nvp;

            r = client.DeleteDomain("MyDomain");
            r = client.CreateDomain("MyDomain");
            
            nvp = new NameValuePairs();
            nvp["Color"] = "Blue";
            nvp["Size"] = "Med";
            nvp["Price"] = "0014.99";
            r = client.PutAttributes("MyDomain", "Item123", nvp);
            r = client.PutAttributes("MyDomain", "Item234", nvp);

            r = client.GetAttributes("MyDomain", "Item123","Color","Price");

            r = client.Query("MyDomain", null, null, null);
            r = client.Query("MyDomain", "['Color' = 'Blue']", null, null);

            nvp = new NameValuePairs();
            nvp["Color"] = "Blue";
            r = client.DeleteAttributes("MyDomain", "Item123", nvp);
            r = client.GetAttributes("MyDomain", "Item123");

            r = client.DeleteAttributes("MyDomain", "Item123", null);
            r = client.GetAttributes("MyDomain", "Item123");

            r = client.DeleteDomain("MyDomain");
            r = client.ListDomains(null, null);

        }   







    }
}
